class Solution {
    public int[] corpFlightBookings(int[][] bookings, int n) {
        int[] b = new int[n+1];
        for (int i = 0; i < n + 1; i++) {
            b[i] = 0;
        }
        for (int[] booking : bookings) {
            b[booking[0]-1] += booking[2];
            b[booking[1]] -= booking[2];
        }
        int[] result = new int[n];
        result[0] = b[0];
        for (int i = 1; i < n; i++) {
            result[i] = result[i-1] + b[i];
        }
        return result;
    }
}